package com.engine4cloud.tdf.education.convert;

import com.engine4cloud.tdf.common.core.util.CodeUtils;
import com.engine4cloud.tdf.education.dto.create.EduCourseCreateDTO;
import com.engine4cloud.tdf.education.dto.result.EduCourseResultDTO;
import com.engine4cloud.tdf.education.dto.update.EduCourseUpdateDTO;
import com.engine4cloud.tdf.education.entity.EduCourseEntity;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;


@Mapper
public interface EduCourseConvert {
    EduCourseConvert INSTANCE = Mappers.getMapper(EduCourseConvert.class);

    EduCourseEntity createTo(EduCourseCreateDTO s);

    EduCourseEntity update(EduCourseUpdateDTO s);

    EduCourseResultDTO convert(EduCourseEntity s);

    default EduCourseEntity create(EduCourseCreateDTO s, Long tenantId) {
        EduCourseEntity entity = createTo(s);
        entity.setCode(CodeUtils.entrustCode());
        entity.setTenantId(tenantId);
        return entity;
    }
}
